package com.koron.common.core.business.workflow.util;

import cn.hutool.core.util.StrUtil;
import com.koron.common.core.business.configsettings.utils.ConfigInfoTool;
import com.koron.common.core.business.workflow.bean.properties.WorkflowProperties;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 工作流模板配置
 * 所属分类为“workflow”
 * 配置编码为processCode
 * @author jzp
 * @since 2021/9/13
 */
@Component
public class WorkflowConfigTool {

    private final String classifyCode = "workflow";

    public WorkflowProperties getConfigByProcessCode(String processCode) {
        Map<String, String> map = ConfigInfoTool.getConfigByCode(classifyCode, processCode);
        String appCode = map.get("appCode");
        if (StrUtil.isEmpty(appCode)) {
            appCode = "yggs";
        }

        return WorkflowProperties.builder()
                .appCode(appCode)
                .processCode(processCode)
                .setCode(map.get("setCode"))
                .moduleCode(map.get("moduleCode"))
                .callbackController(map.get("callbackController")).build();
    }

}
